import { request } from '../utils/request'
import type { UserInfo } from '../types/app.d'

/**
 * 用户登录
 */
export const login = (data: {
  username: string
  password: string
}) => {
  return request.post<{
    token: string
    userInfo: UserInfo
  }>('/user/login', data)
}

/**
 * 获取用户信息
 */
export const getUserInfo = () => {
  return request.get<UserInfo>('/user/info')
}

/**
 * 用户登出
 */
export const logout = () => {
  return request.post('/user/logout')
}

/**
 * 获取用户菜单
 */
export const getUserMenus = () => {
  return request.get<any[]>('/user/menus')
}